#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	int square = n * n;
	int tmp = 0, counter = 0;
	for (int i = 0; square != 0; i++)
	{
		tmp = square % 10;
		if (tmp == 1)
			counter++;
		square /= 10;
	}
	printf("%d\n", counter);
	return 0;
}